package com.lagou.rpc.zookeeper.config;

/**
 * zookeeper全局配置类
 */
public class ZookeeperConfig {
    private static volatile ZookeeperConfig zookeeperConfig;

    //zookeeper地址
    private String zookeeperAddress;

    //是否为服务提供端
    private boolean providerSide;
    //是否为服务消费端口
    private boolean consumerSide;
    //主动上报时间间隔
    private long interval;

    private ZookeeperConfig(){
    }

    //采用单例模式
    public static ZookeeperConfig getInstance() {
        if (zookeeperConfig == null) {
            synchronized (ZookeeperConfig.class) {
                zookeeperConfig = new ZookeeperConfig();
            }
        }
        return zookeeperConfig;
    }


    public String getZookeeperAddress() {
        return zookeeperAddress;
    }

    public void setZookeeperAddress(String zookeeperAddress) {
        this.zookeeperAddress = zookeeperAddress;
    }



    public boolean isProviderSide() {
        return providerSide;
    }

    public void setProviderSide(boolean providerSide) {
        this.providerSide = providerSide;
        this.consumerSide = !providerSide;
    }

    public boolean isConsumerSide() {
        return consumerSide;
    }

    public void setConsumerSide(boolean consumerSide) {
        this.consumerSide = consumerSide;
        this.providerSide = !consumerSide;
    }

    public long getInterval() {
        return interval;
    }

    public void setInterval(long interval) {
        this.interval = interval;
    }
}
